//
//  UserPunishmentListController.m
//  CheekiOS
//
//  Created by mac on 2017/6/23.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "UserPunishmentListController.h"
#import "UserPunishmentCell.h"
@interface UserPunishmentListController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, assign)NSInteger page;
@property (nonatomic, assign)NSInteger rows;

@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSMutableArray *dataSource;



@end

@implementation UserPunishmentListController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavgationBarHiddenNo];
    self.title = @"处罚名单";
    
    _page = 1;
    _rows = 10;
    
    UIView *BackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 150)];
    BackView.backgroundColor = [UIColor clearColor];
    
    UIView *backTextLab = [[UIView alloc] initWithFrame:CGRectMake(10, 10, KScreenWidth-20, BackView.height-20)];
    backTextLab.backgroundColor = Colorbackground;
    [BackView addSubview:backTextLab];
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:backTextLab.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight | UIRectCornerTopLeft | UIRectCornerTopRight  cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = backTextLab.bounds;
    maskLayer.path = maskPath.CGPath;
    backTextLab.layer.mask = maskLayer;
    
    
    UILabel *textLab = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, backTextLab.width-30, backTextLab.height-20)];
    textLab.text = @"共建文明诚信的贴脸儿！发布色情信息、刷广告、恶意侮辱他人、上传假照片等，都可能被暂时或永久封禁账号与上网设备，即使注册信号也无法登陆贴脸儿";
    textLab.numberOfLines = 0;
    textLab.textAlignment = NSTextAlignmentLeft;
    textLab.textColor = [UIColor blackColor];
    
    
 

    [backTextLab addSubview:textLab];
    
    
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-49) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = [UIColor clearColor];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [self.view addSubview:_tableView];
    }
    _tableView.tableHeaderView = BackView;
    
    [self requestDate];
}

- (void)requestDate{
    self.dataSource = [NSMutableArray array];
    [HcardHttpmanager getPunishmentListsWithPage:_page withRows:_rows Success:^(id result) {
        self.dataSource = result;
        [self.tableView reloadData];
    } failure:^(NSError *error) {
        
    }];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSource.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UserPunishmentCell *cell = [UserPunishmentCell cellWithTableView:tableView indexPath:indexPath];
    cell.model = self.dataSource[indexPath.row];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 92.5;
}

@end
